<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <title></title>
    <link rel="stylesheet" href="./css/base.css"/>
    <link rel="stylesheet" href="./css/my_news.css"/>
</head>
<body>
<div class="warp">
    <header class="clearfix">
        <a href="index.html" class="back fl"></a>
        我的消息
    </header>
    <div class="combo">
        <div class="tishi">
            <img src="./images/drawable-xhdpi/icon_1-01.png" alt=""/>
            暂无消息
        </div>
    </div>
</div>
</body>
<script src="./js/base.js"></script>
<script src="./js/jquery-1.12.4.js"></script>
<script src="./lib/layer/layer.js"></script>
<script>
    $('.back').click(function () {
        window.history.back();
    })
    $(function () {
        var sessionId = sessionStorage['sessionId']
        $.post(baseURL + 'yuesao/news/myMessage',{'sessionid':sessionId},function (result) {
            var code = result.code;
            var now = new Date();
            var nowTime = now.getFullYear() + "-" + eval(now.getMonth() +'+1') +  "-" + now.getDate();//当前时间
//            $(".combo").empty()
            if (code == 'USR000') {
                for (var i in result.data.myMessage) {
                    message = result.data.myMessage[i];
                    var div = '<div class="combo_bottom clearfix">'+
                              '<div class="pic fl">'+
                              '<a href="#"></a>'+
                              '</div>'+
                              '<div class="right">'+
                              '<div class="top clearfix">'+
                              '<h3 class="fl">系统消息</h3>'+
                              '<span class="fr">[时间]</span>'+
                              '</div>'+
                              '<div class="text">[内容]</div>'+
                              '</div>'+
                              '</div>'
                    var createDate = new Date(message.createTime);
                    var createTime = createDate.getFullYear() + "-" + eval(createDate.getMonth() + "+1") + "-" + createDate.getDate();
                    div = div.replace('[内容]',message.message);
                    if (nowTime == createTime) {
                        div = div.replace('[时间]','今天')
                    } else {
                        div = div.replace('[时间]',createTime)
                    }
                    $(".combo").append(div)
                }
            } else if (code == 'USER001') {
                $('.tishi').show();
            } else if (code == 'USR102') {
                layer.open({
                    content: "session失效，请重新登录!!",
                    btn: ['确定',],
                    skin: 'my-skin',
                    yes: function (index) {
                        layer.close(index);
                        window.location.href = "login.html";
                    }
                })
            }
        });
    })
</script>
</html>